//
// Created by tsl on 2021/6/23.
//

#include "read_video.h"
#include "opencv2/opencv.hpp"

void read_video(const std::string &src,const std::string &dst){
    cv::VideoCapture capture = cv::VideoCapture(src);

    cv::Mat frame;
    capture.read(frame);
    int width = frame.cols;
    int height = frame.rows;

    cv::VideoWriter videoWriter;
    videoWriter.open(dst,cv::VideoWriter::fourcc('M', 'P', '4', 'V') ,25.0,cv::Size(width,height), true);

    while (frame.data){
        cv::putText(frame,"Wei Xin: cdk198800",cv::Point(10,30),2,1,cv::Scalar(255,0,0),2);
        cv::imshow("frame",frame);
        videoWriter.write(frame);
        cv::waitKey(1);
        capture.read(frame);
    }

    std::cout << "End!" << std::endl;
}